package top.hg.tool.modules.car.user;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.hg.tool.common.util.R;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: skh
 * @Date: 2019/7/30 10:40
 * @Description:
 */
@RestController
@RequestMapping("/car")
@Api(value = "用户管理")
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("登录")
    @GetMapping("/login")
    public R login(String code) {
        UserVO userVO = userService.login(code);
        return R.success(userVO);
    }

    @ApiOperation("增加用户访问量")
    @GetMapping("/addUserVisit")
    public R addUserVisit() {
        Long userVisitCount = userService.addUserVisit();
        Map<String, Long> map = new HashMap<>();
        map.put("userVisitCount", userVisitCount);
        return R.success(map);
    }


    @ApiOperation("设置用户访问量")
    @GetMapping("/setUserVisit")
    public R setUserVisit(Integer initValue) {
        userService.setUserVisit(initValue);
        return R.success();
    }
}
